<template>
    <div>
        <h1>会员信息</h1>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td align="right">会员编号</td>
                    <td>{{info.memberCode}}</td>
                </tr>
                <tr>
                    <td align="right">手机号</td>
                    <td>{{info.tel}}</td>
                </tr>
                <tr>
                    <td align="right">姓名</td>
                    <td>{{info.userName}}</td>
                </tr>
                <tr>
                    <td align="right">证件类型</td>
                    <td>
                        {{info.cardType}}
                    </td>
                </tr>
                <tr>
                    <td align="right">证件号码</td>
                    <td>{{info.card}}</td>
                </tr>
                <tr>
                    <td align="right">会员生日</td>
                    <td>{{info.birthDay}}</td>
                </tr>
                <tr>
                    <td align="right">会员积分</td>
                    <td>{{info.score}}</td>
                </tr>
                <tr>
                    <td align="right">会员余额</td>
                    <td>{{info.money}}</td>
                </tr>
                <tr>
                    <td align="right">会员等级</td>
                    <td>
                        {{info.levelId}}
                    </td>
                </tr>
                <tr>
                    <td align="right">会员性别</td>
                    <td>
                        {{info.gender}}         
                    </td>
                </tr>
                <tr>
                    <td align="right">会员爱好</td>
                    <td>
                        {{info.likes}}
                    </td>
                </tr>
                <tr>
                    <td align="right">会员简介</td>
                    <td>
                        {{info.desc}}
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import{ref,reactive,onMounted} from 'vue';
import axios from 'axios';
import moment from 'moment';
import {useRouter,useRoute}from 'vue-router';
const router=useRouter();
const route=useRoute();
onMounted(()=>{
    getLeveList();
    memberFinds();
})
let arr:any=ref(["身份证","驾驶证","军人证","护照"]);
let info:any =reactive({
    "memberCode": moment(new Date()).format('YYYYMMDD')+Math.random().toString().substr(3,3),
    "tel": "",
    "userName": "",
    "card": "",
    "birthDay": "",
    "score": '',
    "money": '',
    "levelId": '',
    "gender": '',
    "likes": [],
    "desc": "",
    "isagree": '',
    "state": '',
    "cardType":'',
})
//声明一个变量接收等级列表
let lavelist:any=ref([]);
//获取等级列表
const getLeveList=()=>{
    axios({
        url:'/api/Members/GetMemberLevel',
        method:'get',
    })
    .then((res)=>{
        console.log(res);
        lavelist.value=res.data;
    })
    .catch((err)=>{
        console.log(err);
    })
};
const memberFinds=()=>{
    axios({
        url:'/api/Members/FindMember',
        method:'get',
        params:{
            id:route.query.id,
        },
    })
    .then((res)=>{
        console.log(res);
        Object.assign(info,res.data);
        info.birthDay=res.data.birthDay.substring(0,10);//时间反填
        info.likes=res.data.likes.split(',');//将字符串转换成数组
    })
    .catch((err)=>{
        console.log(err);
        
    })
}
</script>
<style scoped>

</style>